<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("div[name='field']").each(function(){
				//var id = $(".title").parent("div[name=field]").index(this) + 1;
				var index = $("div[name='field']").index(this) + 1;
				var title = $(this).children(".title").text();
				
				var aaa = $("div[name='field']:eq(" + (index-1) + ")").attr("id");
				//alert("aaa = " + aaa);
				
				
				var id = "id-" + index;
				var txt = $("#" + id + " .title").text();
				$(this).attr("id", id);
				var input = $("#" + id + " label:").text();
				alert(input);
				
				//alert(index + title);
				
				$("#field-1 input").each(function(){		//遍历每一个选项
					var value = $(this).attr("value");		//获取选项的值
					//alert("value = " + value);
					var opindex = $("#field-1 input").index(this) + 1;
					//alert("value = " + opindex);
				});
				
				//$(this).children(".index").text(id + "、");
				//获取一道题的所有选选项
				//$(this).next(".part").each(function(){
					//var value = $(this).val();
					//alert("value=" + value);
				//	alert("test");
				//});
		});
		
	
		$("#btn").click(function(){
			//var title = $("#field-1 .title").text();
			//var id = $(".title").index($('.title'));
			//$("#area").html("id = " + id + "title = " + title);
			$(".title").each(function(){
				var id = $(".title").index(this) + 1;
				var title = $(this).text();
				//alert("id = " + id + " title" + title);
				
				alert($(".content").html());
				
			});
			


			
		});
		
		
	});
</script>
</head>

<body>



<div class="content">				<!-- 问卷容器 -->

	<div id="field-1" name="field">			<!-- 一道题 -->
	  <div class="head"><span class="index"></span><span class="title">年龄</span></div>		<!-- 标题 -->
        <div class="part">					<!-- 选项 -->
        	<ul class="radioButtonList">
            	<li class="radioButtonList-item">
                	<label><input type="radio" name="field-1" id="field-1-1" value="1"/>25岁以下</label>
                </li>
                <li class="checkboxList-item">
                	<label><input type="radio" name="field-1" id="field-1-2"  value="2" />
                	25岁</label>
                </li>
                <li class="checkboxList-item">
                	<label><input type="radio" name="field-1" id="field-1-3"  value="3" />
                	25岁以上</label>
                </li>
                 <li class="checkboxList-item">
                	<label><input type="radio" name="field-1" id="field-1-3"  value="3" />
                	其他<input type="text" name="field-1" id="field-1-4" /></label>
                </li>
            </ul>
      </div>
  </div>
  
  	<div id="field-2" name="field">					<!-- 一道题 --> 
	  <div class="head"><span class="index"></span><span class="title">性别</span></div>		<!-- 标题 -->
        <div class="part">					<!-- 选项 -->
        	<ul class="radioButtonList">
            	<li class="radioButtonList-item">
                	<label><input type="radio" name="field-2" id="field-2-1" value="1"/>男</label>
                </li>
                <li class="radioButtonList-item">
                	<label><input type="radio" name="field-2" id="field-2-2"  value="2" />女</label>
                </li>
            </ul>
      </div>
  </div>
  
</div>
<div id="area"></div>
<button id="btn" value="显示"/>


</body>
</html>
